#!/usr/bin/env bash
if [ -n "$1" ]
then
    DAY="$1"
else
    DAY=0
fi
DATE=`date --date="$DAY day" +%Y-%m-%d`
file="bigdata_$DATE.gz"
if [ -f "$file" ]
then
	echo "$file found."
else
	echo "download $file."
	sftp -i /c/Users/qianq/Documents/rsa_private root@150.109.38.70:$file

fi
mongorestore --nsInclude bigdata.* --archive=$file --gzip --drop --verbose --db test

echo "done"

read stop